<div class="modal fade" id="compose-message-modal" tabindex="-1" role="dialog" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title"><i class="fa fa-edit"></i> Send mail to jobseeker selected</h4>
			</div>
			<form action="<?php echo base_url(); ?>employers/compose-mail-to-jobseeker" method="post" onsubmit="return validatePassword()" id="compose_email" name="form_change_password">
				<div class="modal-body">
					<div class="form-group">			
						<input id="subject" type="text" name="subject" placeholder="Subject" class="form-control" />			
						
					</div>
					<div class="form-group">			
						<textarea id="message" class="form-control" rows="9" placeholder="Type your message here ..." name="message"></textarea>			
						
					</div>
					<input type="hidden" name="to_jobseeker" id="to_jobseeker" value="" />

				</div>
				<div class="modal-footer clearfix">

					<button id="close_form" type="button" class="btn btn-danger" data-dismiss="modal">
						<i class="fa fa-times"></i> Discard
					</button>

					<button type="submit" class="btn btn-primary pull-left">
						<i class="fa fa-sign-in"></i> Send
					</button>
				</div>
			</form>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<script>
	function validatePassword() {
		var pass = document.forms["form_change_password"]["password"].value;
		var conf_pass = document.forms["form_change_password"]["conf_password"].value;
		var valid = true;
		if (pass == null || pass == "") {
			document.getElementById("error_pass").innerHTML = "Password field must be filled out";
			valid = false;
		} else {
			document.getElementById("error_pass").innerHTML = "";
		}
		if (conf_pass == null || conf_pass == "") {
			document.getElementById("error_conf_pass").innerHTML = "Confirm password field must be filled out";
			valid = false;
		} else {
			document.getElementById("error_conf_pass").innerHTML = "";
		}
		if (conf_pass != pass) {
			document.getElementById("error_pass").innerHTML = "Password field must matches confirm password field";
			valid = false;
		}
		//if (!valid) alert(msg);
		return valid;
	}

</script>
<script>
	function set_null_to_element(){
		$("#message-error").html('');
		$("#subject").val('');
		$("#subject-error").html('');
		$("#message").val('');
		
	}
	$("#close_form").bind("click",function(){
		set_null_to_element()
	});

  $(function() {
  
    // Setup form validation on the #register-form element
    $("#compose_email").validate({
    
        // Specify the validation rules
        rules: {
            subject: {
                required: true
            },
            message: {
                required: true
            }
        },
        
        // Specify the validation error messages
        messages: {
            subject: "Please enter subject",
            message: "Please enter message"
        },
        
        submitHandler: function(form) {
            form.submit();
        }
    });
  });
 
</script>